<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Pencarian extends CI_Controller {
	
	public function __construct()
	{
		parent::__construct();
		$this->load->model('Model_stasiun');
		$this->load->model('Model_pencarian');
		$this->data['head'] = $this->load->view('head','',true);
		$this->data['foot'] = $this->load->view('foot','',true);
	}
	
	public function index()
	{
		$this->data['table'] = $this->Model_stasiun->get_all();
		$this->load->view('pencarian',$this->data);
	}
	
	public function query()
	{
		$input = $this->input->get(NULL, TRUE);
		$this->data['berangkat'] = $this->Model_stasiun->get_one($input['keberangkatan']);
		$this->data['tujuan'] = $this->Model_stasiun->get_one($input['tujuan']);
		$this->data['hasil'] = $this->Model_pencarian->cari($input['keberangkatan'],$input['tujuan'],$input['waktuberangkat'],$input['waktukedatangan']);
		$this->load->view('hasil_pencarian',$this->data);
	}
	
	public function detail()
	{
		$this->load->model('Model_jadwal');
		$input = $this->input->get(NULL, TRUE);
		$this->data['asal'] = $this->Model_stasiun->get_one($input['asal']);
		$this->data['tujuan'] = $this->Model_stasiun->get_one($input['tujuan']);
		$this->data['table'] = $this->Model_jadwal->get_by_kereta($input['id']);
		$this->load->view('detail_kereta',$this->data);
	}
	
}
